<template>
  <view class="bodyView">
    <form>
      <view class="cu-form-group margin-top">
        <view class="title">头像</view>
        <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
          <image class="avatar img-boder" :src="member.url"></image>
        </button>
      </view>
      <view class="cu-form-group">
        <view class="title">法人姓名</view>
        <input type="nickname" maxlength="10" placeholder-style="color:#999;font-size:14px;" placeholder="请填写法人姓名"
               v-model="member.name"  @blur="nameBlur" />
      </view>
      <view class="cu-form-group">
        <view class="title">法人手机号</view>
        <input type="text"  maxlength="11" placeholder-style="color:#999;font-size:14px;" v-model="member.phone" placeholder="请填写法人手机号" @blur="phoneBlur" />
      </view>
      <view class="cu-form-group">
        <view class="title">门店咨询电话</view>
        <input type="text"  maxlength="11" placeholder-style="color:#999;font-size:14px;" v-model="member.storePhone" placeholder="请填写门店咨询电话" />
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">用于后期登录抖音后台开通团购，核销等，客户联系咨询等，一般为常用的门店手机号</view>
      </view>
      <view class="cu-form-group">
        <view class="title">门店ID</view>
        <input type="text" v-if="editPoiId == true" placeholder-style="color:#999;font-size:14px;" v-model="member.poiId" placeholder="请填写门店ID"/>
        <input type="text" v-else disabled placeholder-style="color:#999;font-size:14px;" v-model="member.poiId" placeholder="请填写门店ID"/>
      </view>

      <view class="cu-form-group">
        <view class="title">云连锁门店名称</view>
        <input type="text"  maxlength="11" placeholder-style="color:#999;font-size:14px;" v-model="member.poiName" placeholder="请填写云连锁门店名称" />
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          【请务必按下方提示填写】<br/>
          如：梵好皮肤管理（方洲小区店）<br/>
          梵好皮肤管理（日月路店）<br/>
<!--          <image src="@/static/images/shop/p1.jpg" style="height: 200rpx;" />-->
        </view>
      </view>

      <view class="cu-form-group">
        <view class="title">营业执照名称</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.businessLicense" placeholder="请填写营业执照名称"  />
      </view>

      <view class="cu-form-group">
        <view class="title">营业执照地址</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.address" placeholder="请填写营业执照地址"  />
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          请务必按营业执照如实填写
        </view>
      </view>

      <view class="cu-form-group" style="display:block">
        <view class="title">公共场所卫生许可证</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList" :key="index">
            <image :src="imgList[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('1')" v-if="imgList.length<2">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          上传两张照片
        </view>
      </view>



      <view class="cu-form-group" style="display:block;height: 180rpx;line-height: 90rpx;">
        <view class="title" style="line-height: 40rpx;">门店实际位置定位【请在门店里定位，以免定位错误顾客找不到店】</view>
       <view class="margin-top-lg text-cut" style="line-height: 40rpx">位置:{{member.latitude}},{{member.longitude}}</view>
      </view>


      <radio-group @change="RadioChange" class="margin-bottom-sm margin-top-sm" style="border-top: 1rpx solid #eee;">
        <view class="cu-form-group" style="display:block" >
          <view class="title margin-bottom-xs">之前是否开通过抖音团购</view>
          <radio value="0" :class="member.dredgeDouyin=='0'?'checked':''" :checked="member.dredgeDouyin=='0'?true:false" />没有
          <radio value="1" :class="member.dredgeDouyin=='1'?'checked':''" :checked="member.dredgeDouyin=='1'?true:false" /> 自己上的团购
          <radio value="2" :class="member.dredgeDouyin=='2'?'checked':''" :checked="member.dredgeDouyin=='2'?true:false" /> 加盟别的品牌
        </view>
      </radio-group>

      <radio-group class="margin-bottom-sm margin-top-sm" @change="RadioChange2" style="border-top: 1rpx solid #eee;">
        <view class="cu-form-group" style="display:block" >
          <view class="title margin-bottom-xl" style="line-height: 40rpx;">开通过团购的请如实填写【没开通过团购的不用填写】</view>
          <radio value="0" :class="member.dredgeBuy=='0'?'checked':''" :checked="member.dredgeBuy=='0'?true:false" />已解绑
          <radio value="1" :class="member.dredgeBuy=='1'?'checked':''" :checked="member.dredgeBuy=='1'?true:false" /> 还没解绑
        </view>
      </radio-group>

      <view class="cu-form-group" style="display:block;border-top: 1rpx solid #eee;">
        <view class="title">营业执照</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList2" :key="index">
            <image :src="imgList2[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg2" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('2')" v-if="imgList2.length<4">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          务必露出4个角，拍摄清晰，不能是电子营业执照
        </view>
      </view>


      <view class="cu-form-group"  style="display:block">
        <view class="title">法人身份证正反面</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList3" :key="index">
            <image :src="imgList3[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg3" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('3')" v-if="imgList3.length<2">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          露出四个角
        </view>
      </view>


      <view class="cu-form-group" style="display:block">
        <view class="title">法人收款银行卡号</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.corporationCard" placeholder="请填写法人收款银行卡号"  />
      </view>


      <view class="cu-form-group" style="display: block">
        <view class="title margin-bottom-sm" style="line-height: 40rpx;">法人银行卡开户行(例如:建设银行河南省郑州支行)</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.corporationCardBank" placeholder="请填写法人银行卡开户行"  />
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          务必填写具体银行和开户行，否则影响后期资金到账
        </view>
      </view>

      <view class="cu-form-group" style="display:block">
        <view class="title">门头照片</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList4" :key="index">
            <image :src="imgList4[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg4" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('4')" v-if="imgList4.length<9">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          正面照1张，侧面照2张，需包含完整门头，显示旁边店铺街景，参考下列示例图<br/>
          数量限制：至多9张
        </view>
      </view>

      <view class="cu-form-group" style="display:block">
        <view class="title">店内环境照片3张</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList5" :key="index">
            <image :src="imgList5[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg5" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('5')" v-if="imgList5.length<3">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          大厅、前台，工作间<br/>
          数量限制：至多3张
        </view>
      </view>


      <view class="cu-form-group" style="display: block">
        <view class="title">抖音号截图</view>
        <view class="grid col-4 grid-square flex-sub">
          <view class="bg-img" v-for="(item,index) in imgList6" :key="index">
            <image :src="imgList6[index]" mode="aspectFill"></image>
            <view class="cu-tag bg-red" @tap.stop="DelImg6" :data-index="index">
              <text class='cuIcon-close'></text>
            </view>
          </view>
          <view class="solids" @tap="uploadImages('6')" v-if="imgList6.length<2">
            <text class='cuIcon-cameraadd'></text>
          </view>
        </view>
      </view>
      <view class="cu-form-group b-top">
        <view class="text-desc">
          需绑定为门店蓝V账号的抖音首页截图（包含名称+抖音号）【抖音号必须是个人号】 在抖音右下方-我的界面查看<br/>
          数量限制：至多2张
        </view>
      </view>

      <view class="cu-form-group" style="display: block">
        <view class="title">门牌收货地址</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.deliveryAddress" placeholder="请填写门牌收货地址"  />
      </view>

      <view class="cu-form-group">
        <view class="title">营业时间</view>
        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.businessHour" placeholder="请填写营业时间"  />
      </view>




<!--      <view class="cu-form-group">-->
<!--        <view class="title">门店ID</view>-->
<!--        <input type="text" v-if="editPoiId == true" placeholder-style="color:#999;font-size:14px;" v-model="member.poiId" placeholder="请填写门店ID"/>-->
<!--        <input type="text" v-else disabled placeholder-style="color:#999;font-size:14px;" v-model="member.poiId" placeholder="请填写门店ID"/>-->
<!--      </view>-->
<!--      <view class="cu-form-group">-->
<!--        <view class="title">门店名称</view>-->
<!--        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.poiName" placeholder="请填写门店名称"  />-->
<!--      </view>-->
<!--      <view class="cu-form-group">-->
<!--        <view class="title">门店地址</view>-->
<!--        <input type="text" placeholder-style="color:#999;font-size:14px;" v-model="member.address" placeholder="请填写门店地址"/>-->
<!--      </view>-->

      <view class="cu-form-group">
        <view class="title">介绍</view>
        <textarea class="text-area"  v-model="member.remark" maxlength="200" placeholder-style="color:#999;font-size:14px;" placeholder="这里可以介绍一下门店哦"></textarea>
      </view>


      <button class="cu-btn block margin-tb-sm lg text-custom-bg text-white btn" @click="save">确认</button>
    </form>
  </view>
</template>

<script setup lang="ts">
import env from '@/common/utils/env';
import {onMounted, ref, reactive, computed} from "vue";
import {onLoad, onReady, onShow} from '@dcloudio/uni-app';
import { updateUserInfo, getUser} from "@/common/api/user";
import {useStore} from "../../common/store";
const store = useStore();
const token = computed(() => store.token)
onLoad((options) => {
  uni.getLocation({
    type:'gcj02',
    success(res){
      member.latitude = res.latitude
      member.longitude = res.longitude
      console.log('res.latitude',res.latitude,'res.longitude',res.longitude);
    }
  })
});

const emit = defineEmits(["closeBooking"])

const editPoiId = ref(false)
// 用户信息
const member = reactive({
  url: '',
  username: '',
  phone:'',
  poiId: '',
  poiName: '',
  address: '',
  openId: token.value,
  pass: '12345678',
  pass2: '12345678',
  email: '',
  name: '',
  remark:'',
  id: 0,
  storePhone: '',
  businessLicense: '',
  dredgeBuy: '0',
  dredgeDouyin: '',
  corporationCard: '',
  corporationCardBank: '',
  deliveryAddress: '',
  businessHour: '',
  latitude:'',
  longitude:'',
  corporation: '',
  corporationPhone: '',
  sanitaryLicensePhoto: '',
  sanitaryLicensePhotos: [],
  businessLicensePhoto: '',
  businessLicensePhotos: [],
  corporationPhoto: '',
  corporationPhotos: [],
  doorPhoto: '',
  doorPhotos: [],
  evnPhoto: '',
  evnPhotos: [],
  douyinPhoto: '',
  douyinPhotos: [],
});

// const handleDateChange = (e) => {
//   member.birthday = e.target.value
// }

const imgList = ref([])
const imgList2 = ref([])
const imgList3 = ref([])
const imgList4 = ref([])
const imgList5 = ref([])
const imgList6 = ref([])
// 抖音团购
const radioTG = ref('0')
// 解绑
const radioJB = ref('1')

const RadioChange = (e)=> {
  member.dredgeDouyin = e.detail.value
}
const RadioChange2 = (e)=> {
  member.dredgeBuy = e.detail.value
}

const uploadImages = (type) => {
  uni.chooseImage({
    count: 1, //默认9
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    success: async (res) => {
      await uploadImage(res.tempFilePaths[0]).then(res=>{
        if(type == '1') {
          if (imgList.value.length != 0) {
            imgList.value = imgList.value.concat([res])
          } else {
            imgList.value = [res]
          }
        } else if (type=='2') {
          if (imgList2.value.length != 0) {
            imgList2.value = imgList2.value.concat([res])
          } else {
            imgList2.value = [res]
          }
        } else if(type == '3') {
          if (imgList3.value.length != 0) {
            imgList3.value = imgList3.value.concat([res])
          } else {
            imgList3.value = [res]
          }
        } else if(type == '4') {
          if (imgList4.value.length != 0) {
            imgList4.value = imgList4.value.concat([res])
          } else {
            imgList4.value = [res]
          }
        }  else if(type == '5') {
          if (imgList5.value.length != 0) {
            imgList5.value = imgList5.value.concat([res])
          } else {
            imgList5.value = [res]
          }
        }  else if(type == '6') {
          if (imgList6.value.length != 0) {
            imgList6.value = imgList6.value.concat([res])
          } else {
            imgList6.value = [res]
          }
        }
      }).catch(e=>{
        uni.showToast({
          title: '上传失败,请重试！',
          duration: 2000,
          icon: 'none'
        });
      })

    }
  });
}

const onChooseAvatar = async (e) =>{
  await uploadImage(e.detail.avatarUrl).then(res=>{
    member.url = res
  }).catch(e=>{
    uni.showToast({
      title: '上传失败,请重试！',
      duration: 2000,
      icon: 'none'
    });
  })
}

const DelImg = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        console.log('e:',imgList.value.length)
        imgList.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}
const DelImg2 = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        imgList2.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}

const DelImg3 = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        imgList3.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}

const DelImg4 = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        imgList4.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}


const DelImg5 = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        imgList5.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}


const DelImg6 = (e) => {
  uni.showModal({
    title: '提示',
    content: '确定要删除？',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
      if (res.confirm) {
        imgList6.value.splice(e.currentTarget.dataset.index, 1)
      }
    }
  })
}

const uploadImage = (filePath) => {
  console.log('filepath:',filePath)
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: `${env.baseurl}/api/user/uploadImage`,
      filePath: filePath,
      name: 'file',
      success: (uploadFileRes) => {
        const data = JSON.parse(uploadFileRes.data);
        if (data && data.code == '200') {
          resolve(data.data.url);
        } else {
          reject("网络忙稍候重试!");
        }
      },
      fail: (error) => {
        reject(error);
      },
    });
  })
}


const save = async () => {
  if (!member.url) {
    uni.showToast({
      title: '请上传头像',
      duration: 2000,
      icon: 'none'
    });
    return false
  }

  if (!member.name) {
    uni.showToast({
      title: '门店管理员名称不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }

  if (!member.phone) {
    uni.showToast({
      title: '手机号不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (!member.storePhone) {
    uni.showToast({
      title: '门店咨询电话不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (!member.poiName) {
    uni.showToast({
      title: '云连锁门店名称不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (!member.businessLicense) {
    uni.showToast({
      title: '营业执照名称不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (!member.address) {
    uni.showToast({
      title: '营业执照地址不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }


  if (imgList.value.length != 2) {
    uni.showToast({
      title: '请上传公共场所卫生许可证图片',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['sanitaryLicensePhotos']=imgList.value
  console.log('member.dredgeBuy:',member.dredgeBuy,member)
  if (!member.dredgeBuy) {
    uni.showToast({
      title: '请选择之前是否开通过抖音团购',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (imgList2.value.length == 0) {
    uni.showToast({
      title: '请上传营业执照图片',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['businessLicensePhotos']=imgList2.value

  if (imgList3.value.length < 2) {
    uni.showToast({
      title: '请上传法人身份证正反面',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['corporationPhotos']=imgList3.value

  if (!member.corporationCard) {
    uni.showToast({
      title: '请填写法人收款银行卡号',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  if (!member.corporationCardBank) {
    uni.showToast({
      title: '请填写法人银行卡开户行',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }

  if (imgList4.value.length == 0) {
    uni.showToast({
      title: '请上传门头照片',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['doorPhotos']=imgList4.value

  if (imgList5.value.length == 0) {
    uni.showToast({
      title: '请上传店内环境照片3张',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['evnPhotos']=imgList5.value
  if (imgList6.value.length == 0) {
    uni.showToast({
      title: '请上传抖音号截图',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  member['douyinPhotos']=imgList6.value

  if (!member.deliveryAddress) {
    uni.showToast({
      title: '门牌收货地址不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }

  if (!member.businessHour) {
    uni.showToast({
      title: '营业时间不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }

  if (!member.poiId) {
    uni.showToast({
      title: '门店编号不能为空',
      duration: 2000,
      icon: 'none'
    });
    return false;
  }
  // if (!member.poiName) {
  //   uni.showToast({
  //     title: '门店名称不能为空',
  //     duration: 2000,
  //     icon: 'none'
  //   });
  //   return false;
  // }
  //
  // if (!member.address) {
  //   uni.showToast({
  //     title: '门店地址不能为空',
  //     duration: 2000,
  //     icon: 'none'
  //   });
  //   return false;
  // }

  member.username = member.phone
  await updateUserInfo(member).then(res => {
    store.$patch({
      avatarUrl: member.url,
      userName: member.name
    })
    uni.showToast({
      icon: 'none',
      duration: 2000,
      title: `${res.message}`
    });
    setTimeout(() => {
      uni.navigateBack({
        delta: 1
      }, 2000);
    })
  })
}


const nameBlur = (e) => {
  member.name = e.detail.value
}

const usernameBlur = (e) => {
  member.username = e.detail.value
  if (!member.username) {
    uni.showToast({
      icon: 'none',
      duration: 3000,
      title: `请填写用户名`
    });
    member.username = ''
    return
  }
  var reg = /^[A-Za-z0-9]+$/;
  if (!reg.test(member.username)) {
    uni.showToast({
      icon: 'none',
      duration: 3000,
      title: `用户名为数字字或符串`
    });
    member.username = ''
    return;
  }
}

const phoneBlur = () => {
  if (!member.phone) {
    uni.showToast({
      icon: 'none',
      duration: 3000,
      title: `请填写手机号码`
    });
    return
  }

  var reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  if (!reg.test(member.phone)) {
    uni.showToast({
      icon: 'none',
      duration: 3000,
      title: `手机号码有误，请重新输入!`
    });
    // member.phone= ''
    return;
  }
}

const getUserInfo = async () => {
  if(token.value) {
    await getUser(token.value).then(r => {
      if(r && r.data) {
        let res = r.data;
        member.name = res.name;
        member.phone = res.phone;
        member.url = res.url;
        member.sex = res.sex;
        member.remark = res.remark;
        member.id = res.id;
        member.storePhone = res.ownerShop.storePhone;
        member.businessLicense = res.ownerShop.businessLicense;
        member.address = res.ownerShop.address;
        member.dredgeBuy = res.ownerShop.dredgeBuy||0;
        member.dredgeDouyin = res.ownerShop.dredgeDouyin||0;
        member.corporationCard = res.ownerShop.corporationCard;
        member.corporationCardBank = res.ownerShop.corporationCardBank;
        member.deliveryAddress = res.ownerShop.deliveryAddress;
        member.businessHour = res.ownerShop.businessHour;

        member.poiId = res.ownerShop.poiId;
        member.poiName = res.ownerShop.poiName;

         member.corporation= res.ownerShop.corporation
         member.corporationPhone= res.ownerShop.corporationPhone
         member.sanitaryLicensePhoto= res.ownerShop.sanitaryLicensePhoto
         member.sanitaryLicensePhotos= res.ownerShop.sanitaryLicensePhotos
         member.businessLicensePhoto=res.ownerShop.businessLicensePhoto
         member.businessLicensePhotos=res.ownerShop.businessLicensePhotos
         member.corporationPhoto=res.ownerShop.corporationPhoto
         member.corporationPhotos=res.ownerShop.corporationPhotos
         member.doorPhoto= res.ownerShop.doorPhoto
         member.doorPhotos= res.ownerShop.doorPhotos
         member.evnPhoto= res.ownerShop.evnPhoto
         member.evnPhotos= res.ownerShop.evnPhotos
         member.douyinPhoto= res.ownerShop.douyinPhoto
         member.douyinPhotos= res.ownerShop.douyinPhotos

        if (member.poiId) {
          editPoiId.value == false;
        } else {
          editPoiId.value = true;
        }
        if(res.ownerShop.sanitaryLicensePhoto) {
          imgList.value = res.ownerShop.sanitaryLicensePhoto.split(',')
        }
        if(res.ownerShop.businessLicensePhoto) {
          imgList2.value = res.ownerShop.businessLicensePhoto.split(',')
        }
        if(res.ownerShop.corporationPhoto) {
          imgList3.value = res.ownerShop.corporationPhoto.split(',')
        }
        if(res.ownerShop.doorPhoto) {
          imgList4.value = res.ownerShop.doorPhoto.split(',')
        }
        if(res.ownerShop.evnPhoto) {
          imgList5.value = res.ownerShop.evnPhoto.split(',')
        }
        if(res.ownerShop.douyinPhoto) {
          imgList6.value = res.ownerShop.douyinPhoto.split(',')
        }

        store.$patch({
          avatarUrl: res.url,
          userId: res.id,
          userName: res.name,
          hasLogin: true,
          phone: res.phone,
          token: token.value,
          qrcode: res.qrcode,
          promoCode: res.promoCode,
          auditStatus: res.auditStatus,
          adminLevel: res.adminLevel,
          adminLevelName: res.adminLevelName,
          promoCodeUrl: res.promoCodeUrl,
          upgradePreLevel: res.upgradePreLevel,
          upgradeLevel: res.upgradeLevel,
          upgradeTime: res.upgradeTime,
          city: res.city,
          ownerShop: res.ownerShop
        })
      } else {
        store.$patch({
          avatarUrl: '',
          userId: '',
          userName: '',
          hasLogin: false,
          phone: '',
          qrcode: '',
          promoCode: '',
          promoCodeUrl: '',
          adminLevel: 0,
          adminLevelName: '',
          auditStatus: 0,
          upgradePreLevel: '',
          upgradeLevel: '',
          upgradeTime: '',
          city: '',
          ownerShop: {
            poiId: '',
            poiName: '',
            address:'',
            cardType:'',
            cardStartTime:'',
            cardEndTime:'',
            corporation: '',
            corporationPhone: '',
            storePhone: '',
            businessLicense: '',
            sanitaryLicensePhoto: '',
            sanitaryLicensePhotos: [],
            dredgeDouyin: '',
            dredgeBuy: '',
            businessLicensePhoto: '',
            businessLicensePhotos: [],
            corporationPhoto: '',
            corporationPhotos: [],
            corporationCard: '',
            corporationCardBank: '',
            doorPhoto: '',
            doorPhotos: [],
            evnPhoto: '',
            evnPhotos: [],
            douyinPhoto: '',
            douyinPhotos: [],
            deliveryAddress: '',
            businessHour: ''
          }
        })
        uni.showToast({ //提示
          duration: 5000,
          title: '未查询到用户信息，请先注册！',
        })
        setTimeout(() => {
          uni.navigateTo({
            url: `/pages/user/register`
          })
        }, 1500)

      }
    }).catch(e=>{

    })
  }
}

onMounted(async () => {
  await getUserInfo()
})
</script>

<style lang="scss" scoped>

.bodyView {
  margin: 10rpx;
  .cu-form-group .title {
    min-width: calc(4em + 15px);
  }
  .img-boder{
    border-radius: 50%;
  }
  .radio-group {
    display: flex;
    justify-content: flex-start;

    .radio {
      padding: 10rpx 30rpx;
      border-radius: 10rpx;
      border: 2rpx solid #909090;
      color: #919293;
      font-size: 28rpx;

      &.checked {
        background-color: #EAB769;
        color: #ffffff;
        border: 2rpx solid transparent;
      }
    }
  }
}


.form {
  border-radius: 8rpx;
}

.form-input {
  margin-top: 20rpx;
  .label {
    width: 160rpx;
    font-size: 32rpx   ;
    color: #5A5B5C;
    text-align: right;
    padding-right: 14rpx;
    margin-top: 2rpx;

  }

  .input {
  }

  .radio-group {
    display: flex;
    justify-content: flex-start;

    .radio {
      padding: 10rpx 30rpx;
      border-radius: 6rpx;
      border: 2rpx solid #919293;
      color: #919293;
      font-size: 28rpx;

      &.checked {
        background-color: #ADB838;
        color: #ffffff;
        border: 2rpx solid #ADB838;
      }
    }
  }
}

.d-flex {
  display: flex;
}

.flex-fill {
  -ms-flex: 1 1 auto !important;
  flex: 1 1 auto !important;
  textarea {
    height: 200rpx;
    width: 96%;
  }
}

.w-100 {
  width: 100% !important;
}

.align-items-center {
  align-items: center;
}

.align-items-left {
  align-items: left;
}

.avatar-wrapper {
  padding: 0;
  margin: 0;
  width: 35px !important;
  border-radius: 8px;
}

.avatar {
  display: block;
  width: 35px;
  height: 35px;
  z-index: 1;
}
.button {
  background-color: green;
  margin: 20rpx;
}

.text-area{
  background: #F8F8F8;
  border-radius: 10rpx;
  height: 234rpx;
  padding-top: 20rpx;
  padding-left: 20rpx;
}
.btn{
  margin-bottom: 20rpx;
  margin-right: 30rpx;
  margin-left: 30rpx;
}
.text-desc{
  font-size: 22rpx;
  color: #8E8E8E;
}
.b-top{
  margin-top: -20rpx;
  border-top: 1rpx solid transparent;
}
</style>
